home *** CD-ROM | disk | FTP | other *** search
- /*------------------------------------------------------------------------------
- *
- * Apple Macintosh Developer Technical Support
- *
- * Installer 3.1 sample: Action Atoms
- *
- * File: ActionAtomSample.c - c Source
- *
- * by: Jon Zap
- *
- * Copyright © 1990-1991 Apple Computer, Inc.
- * All rights reserved.
- *
- *----------------------------------------------------------------------------*/
- #if 0
- c -b ActionAtomSample.c
- Link -ra =resPurgeable -rt infn=1001 -rn -m ACTIONATOM -t rsrc -c RSED ∂
- ActionAtomSample.c.o ∂
- -o ActionAtomSample.rsrc
- #endif
-
- #include <Traps.h>
- #include <Types.h>
- #include <QuickDraw.h>
- #include <Memory.h>
- #include <Files.h>
- #include <Resources.h>
- #include <Dialogs.h>
- #include <StandardFile.h>
- #include <ActionAtomIntf.h>
- #include "ActionAtomSelectors.h"
-
- #define NIL 0
-
- Boolean AlertAtom();
-
- pascal Boolean ACTIONATOM(AAPBRecPtr AB)
- {
- switch (AB->aaRefCon) { /* switch is useless here but we assume that we'll add other userFunctions */
-
- case ShowAlertSelector:
- return AlertAtom();
- }
- }
-
- Boolean AlertAtom()
- {
- unsigned short screenWidth,screenHeight,alertWidth, alertHeight;
- GrafPtr myPort,thePort;
- Rect alertRect,t;
- AlertTHndl theAlert;
-
-
- GetPort(&myPort); // save Installer GrafPort
-
- theAlert = (AlertTHndl) GetResource('ALRT',128); // get the alert template
- HLock ((Handle)theAlert); // don't want to lose it
- alertRect = *(Rect *)*theAlert;
- alertWidth = alertRect.right - alertRect.left; // calculate alert width
- alertHeight = alertRect.bottom - alertRect.top; // calculate alert height
-
- GetWMgrPort(&thePort); // get desktop window port
- t = thePort->portRect;
- screenWidth = t.right - t.left; // calc screen width
- screenHeight = t.bottom - t.top; // and height
-
- alertRect.left = t.left + ((screenWidth - alertWidth) >> 1); // center alert on screen. calc new left.
- alertRect.right = alertRect.left + alertWidth; // calc new right
- alertRect.top = 10 + t.top + ((screenHeight - alertHeight) >> 1);// calc new top
- alertRect.bottom = alertRect.top + alertHeight; // calc new bottom
- *(Rect *)*theAlert = alertRect;
-
- (void) NoteAlert(128,NIL); // do alert
- HUnlock ((Handle)theAlert); // free it up
- DetachResource((Handle)theAlert); // don't re-write ALRT with new rectangle
-
- SetPort(myPort); // give the port back
- return true;
-
- }
-